#include <cctype>

#include<iostream>
#include<string>
using namespace std;

#include <cctype>
#include<string>
class Solution {
public:
    int StrToInt(string str) {
        int flag = 1;
        int start = 0;
        string s;
        if (str[start] == '-')
        {
            flag = -1;
            start++;
        }
        else if (str[start] == '+')
        {
            start++;
        }
        if (start >= str.size()) return 0;
        for (int i = start; i < str.size(); i++)
        {
            if (isdigit(str[i]))
            {
                s += str[i];
            }
            else
            {
                return 0;
            }
        }
        long long res = stoll(s);
        if (flag == -1)
            res *= -1;
        cout << res;
        return res;
    }
};

    void main()
    {
        Solution s1;
        s1.StrToInt("+12345a7899874");

    }
